import com.sun.deploy.util.ArrayUtil;

import java.util.Arrays;
import java.util.List;
import java.util.Stack;
import java.util.stream.Collectors;

public class CQueue {
    public Stack<Integer> sk1;
    public Stack<Integer> sk2;

    public CQueue() {
        sk1 = new Stack<>();
        sk2 = new Stack<>();
    }

    public void appendTail(int value) {
        sk1.push(value);
    }

    public int deleteHead() {
        if (sk1.isEmpty() && sk2.isEmpty()) {
            return -1;
        }
        if (sk2.isEmpty()) {
            while (!sk1.isEmpty()) {
                sk2.push(sk1.pop());
            }
        }
        return sk2.pop();
    }

    public static void main(String[] args) {
        CQueue cQueue = new CQueue();
        cQueue.appendTail(1);
        cQueue.appendTail(2);
        cQueue.appendTail(4);
        cQueue.appendTail(5);
        System.out.println(cQueue.deleteHead());

//        List<Integer> list = Arrays.stream( src ).boxed().collect(Collectors.toList());
    }
}